#include "MyAudioLibrary.h"

MyAudioLibrary::MyAudioLibrary(HardwareSerial &serial) : _serial(serial) {
}

void MyAudioLibrary::volume(unsigned char vol) {
    unsigned char mapped_vol = (vol * 30) / 100;
    unsigned char volume[5] = {0xAA, 0x13, 0x01, mapped_vol, 0};
    volume[4] = volume[0] + volume[1] + volume[2] + volume[3];
    _serial.write(volume, 5);
}

void MyAudioLibrary::play(unsigned char track) {
    unsigned char play[6] = {0xAA, 0x07, 0x02, 0x00, track, track + 0xB3};
    _serial.write(play, 6);
}
